package studio.servletArmado;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import studio.modelo.Administrador;
import studio.modelo.Armado;

/**
 * Servlet implementation class LimpiarArm
 */
public class LimpiarArm extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LimpiarArm() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.processRequest(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.processRequest(request, response);
	}
	
	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HttpSession sesion = request.getSession();
		Administrador objAdm=(Administrador)sesion.getAttribute("Admin_Actual");
		if (objAdm==null)
		{
			response.sendRedirect("Login.jsp");
		}
		else
		{
			Armado objArmadoSesion=(Armado)sesion.getAttribute("Armado");
			if(objArmadoSesion !=null)
			{
				System.out.println(" no esta nulo");
				objArmadoSesion=null;
				sesion.setAttribute("Armado", objArmadoSesion);
				response.sendRedirect("ArmadoSala.jsp");
			}
			else
			{
				System.out.println(" esta nulo");
				response.sendRedirect("ArmadoSala.jsp");
			}
		}
	}

}
